import request from '@/utils/request'

// 还款计划管理接口
export const repaymentPlanApi = {
  // 获取还款计划列表
  getList(params) {
    return request({
      url: '/repayment/plan/list',
      method: 'get',
      params
    })
  },
  
  // 生成还款计划
  generate(data) {
    return request({
      url: '/repayment/plan/generate',
      method: 'post',
      data
    })
  },
  
  // 批量生成还款计划
  batchGenerate(data) {
    return request({
      url: '/repayment/plan/batch-generate',
      method: 'post',
      data
    })
  },
  
  // 获取还款计划详情
  getPlanDetail(planId) {
    return request({
      url: `/repayment/plan/${planId}`,
      method: 'get'
    })
  },
  
  // 通过贷款编号获取还款计划
  getPlanByLoanNo(loanNo) {
    return request({
      url: `/repayment/plan/loan/${loanNo}`,
      method: 'get'
    })
  },
  
  // 调整还款计划
  adjustPlan(data) {
    return request({
      url: '/repayment/plan/adjust',
      method: 'put',
      data
    })
  },
  
  // 计算罚息
  calculatePenalty(data) {
    return request({
      url: '/repayment/plan/calculate-penalty',
      method: 'post',
      data
    })
  },
  
  // 获取还款计划统计数据
  getStatistics() {
    return request({
      url: '/repayment/plan/statistics',
      method: 'get'
    })
  },
  
  // 导出还款计划
  exportPlan(params) {
    return request({
      url: '/repayment/plan/export',
      method: 'get',
      params,
      responseType: 'blob'
    })
  },
  
  // 导出还款计划明细
  exportPlanDetail(planId) {
    return request({
      url: `/repayment/plan/export-detail/${planId}`,
      method: 'get',
      responseType: 'blob'
    })
  },
  
  // 获取贷款编号下拉列表
  getLoanNumbers(params) {
    return request({
      url: '/repayment/plan/loan-numbers',
      method: 'get',
      params
    })
  },
  
  // 获取客户姓名下拉列表
  getCustomerNames(params) {
    return request({
      url: '/repayment/plan/customer-names',
      method: 'get',
      params
    })
  },
  
  // 获取还款状态列表
  getRepayStatuses() {
    return request({
      url: '/repayment/plan/statuses',
      method: 'get'
    })
  },
  
  // 获取还款方式列表
  getPaymentMethods() {
    return request({
      url: '/repayment/plan/payment-methods',
      method: 'get'
    })
  },
  
  // 获取已批准的贷款列表
  getApprovedLoans(params) {
    return request({
      url: '/loan/apply/list',
      method: 'get',
      params
    })
  }
}

// 还款记录管理接口
export const repaymentRecordApi = {
  // 获取还款记录列表
  getList(params) {
    return request({
      url: '/repayment/record/list',
      method: 'get',
      params
    })
  },
  
  // 记录还款
  add(data) {
    return request({
      url: '/repayment/record',
      method: 'post',
      data
    })
  },
  
  // 获取还款详情
  getInfo(recordId) {
    return request({
      url: `/repayment/record/${recordId}`,
      method: 'get'
    })
  }
}

// 逾期管理接口
export const overdueApi = {
  // 获取逾期列表
  getList(params) {
    return request({
      url: '/repayment/overdue/list',
      method: 'get',
      params
    })
  },
  
  // 发送还款提醒
  sendRemind(data) {
    return request({
      url: '/repayment/overdue/remind',
      method: 'post',
      data
    })
  },
  
  // 批量发送提醒
  batchRemind(data) {
    return request({
      url: '/repayment/overdue/batch-remind',
      method: 'post',
      data
    })
  },
  
  // 催收登记
  collectRegister(data) {
    return request({
      url: '/repayment/overdue/collect',
      method: 'post',
      data
    })
  },
  
  // 获取催收记录
  getCollectRecords(overdueId) {
    return request({
      url: `/repayment/overdue/collect/${overdueId}`,
      method: 'get'
    })
  },
  
  // 逾期还款
  overdueRepay(data) {
    return request({
      url: '/repayment/overdue/repay',
      method: 'post',
      data
    })
  },
  
  // 获取逾期统计数据
  getOverdueStatistics(params) {
    return request({
      url: '/repayment/overdue/statistics',
      method: 'get',
      params
    })
  }
}

// 还款统计接口
export const repaymentStatisticsApi = {
  // 获取还款统计数据
  getStatistics(params) {
    return request({
      url: '/repayment/statistics',
      method: 'get',
      params
    })
  }
} 